<template>
  <div class="box">
    <img :src="url">
    <p @click="like" :style="{'background-color':color}">{{name}}</p>
  </div>
</template>

<script>
export default {
  data(){
    return{
       a:0,
      b:0,
      c:0,
      color:''
      
    }
  },
  props: ['url','name'],
  methods:{
    like(){
      this.$emit('xihuan',this.name)
          this.a=Math.floor(Math.random()*256)
    this.b=Math.floor(Math.random()*256)
    this.c=Math.floor(Math.random()*256)
    this.color='rgb('+this.a+','+this.b+','+this.c+')'
    }
  }
}
</script>

<style>
.box{
  width: 300px;
  border: 1px solid black;
  text-align: center;
  float: left;
}
img{
  width: 100%;
  height: 300px;
  /* background-color: rgba(255,255,255,0); */
  
}
</style>